package com.wangqinlei.cowims126.service.impl;

import com.wangqinlei.cowims126.mapper.BreederMapper;
import com.wangqinlei.cowims126.pojo.Breeder;
import com.wangqinlei.cowims126.service.BreederService;
import com.wangqinlei.cowims126.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Classname BreederServiceImpl
 * @Description None
 * @Date 2019/6/28 18:56
 * @Created by WDD
 */
@Service
public class BreederServiceImpl implements BreederService {

    @Autowired
    private BreederMapper breederMapper;

    @Override
    public PageBean<Breeder> queryPage(Map<String, Object> paramMap) {
        PageBean<Breeder> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Breeder> datas = breederMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = breederMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public int deleteBreeder(List<Integer> ids) {
        return breederMapper.deleteBreeder(ids);
    }

    @Override
    public int addBreeder(Breeder breeder) {
        return breederMapper.addBreeder(breeder);
    }

    @Override
    public Breeder findById(Integer bid) {
        return breederMapper.findById(bid);
    }

    @Override
    public int editBreeder(Breeder breeder) {
        return breederMapper.editBreeder(breeder);
    }

    @Override
    public Breeder findByBreeder(Breeder breeder) {
        return breederMapper.findByBreeder(breeder);
    }

    @Override
    public int editPswdByBreeder(Breeder breeder) {
        return breederMapper.editPswdByBreeder(breeder);
    }

    @Override
    public int findByName(String name) {
        return breederMapper.findByName(name);
    }
}
